Linear Mixed Model

First, What does mixed-effects mean

Mixed-effects models

Mixed model vs. Multilevel model vs. Hierarchical model

| Model | Emphasize |
| ---------------------- | -------------------------------------- |
| Mixed model | fixed + random effects |
| Multilevel model | nested / clustered data structure |
| Hierarchical model | hierarchical model/parameter structure |

  • They all describe the same framework from different angles.
  • Hierarchical model is the broadest term.

Fixed effects vs. random effects

Fixed effects

Random effects

Linear mixed model (LMM)

What is LMM

LMM vs. GLMM

  • LMM is mainly for continuous outcomes that are approximately normally distributed.
  • For binary, count, ordinal, or categorical outcomes, use a generalized linear mixed model (GLMM) instead.

Formula

Y=Xβ+Zb+ϵ
Compared to ANOVA & Post-hoc Tests, a basic ANOVA model does not include the random-effect term:
Y=Xβ+ϵ

Intuition of the formula

Example: Random Intercept + Random Slope

For Longitudinal Data Analysis, a common LMM is:

Yij=(β0+b0i)+(β1+b1i)tij+ϵij

Thus, each individual has their own trajectory:

intercepti=β0+b0islopei=β1+b1i

Variance components

Random effects describe how individuals differ from the population-average. Their variability is summarized by variance components.

Hint

Variance components represent remaining unexplained variability after accounting for the fixed effects.

  • Large random-intercept variance → individuals still differ in baseline levels.
  • Large random-slope variance → individuals still differ in rates of change.
  • Large (level-1/within-person) residual variance → substantial within-person variation remains unexplained.
  • Intercept–slope covariance:
    • positive → individuals with higher-than-average baselines tend to have higher slopes
    • negative → individuals with higher-than-average baselines tend to have lower slopes
    • near zero → little association between baseline deviation and rate-of-change deviation

They helps identify where additional predictors may be useful:

  • within-person variation → consider time-varying predictors
  • between-person variation → consider individual/group-level predictors

Example: Random Intercept + Random Slope

For a random-intercept + random-slope model:

bi=(b0ib1i)∼N(0,G)

where

G=(σ02σ01σ01σ12)

Why LMM matters

Compared to ANOVA

Compared to ANOVA & Post-hoc Tests, LMM is more flexible:

When to use LMM

Use LMM when:

Assumptions for using LMM

Sampling and independence

Distribution assumptions

Covariance structure

How to build an LMM

General modeling decisions:

  1. Decide fixed effects
    • What population-level relationships should be estimated?
  2. Decide random effects
    • Which grouping variable should have random effects?
    • Random intercept only, or random intercept + random slope?
  3. Decide Covariance Structure
    • Which structure best describes within-subject or within-group correlation?
  4. Compare candidate models
    • Use likelihood ratio tests, AIC / BIC, or cross-validation
    • Prefer the model that is interpretable and fits the dependency structure well
    • Avoid making the random-effects structure too complex if the data cannot support it
Tip

For repeated-measures / growth-curve applications, see Longitudinal Mixed Model Workflow.